﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MIS.Logistics.Website.Models;

namespace MIS.Logistics.Website.Controllers
{
    [HandleError]
    [UserAuthorize]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "欢迎使用 ASP.NET MVC!";

            return View();
        }
        public ActionResult Admin()
        {
            ViewData["Message"] = "只有管理员才能访问!";

            return View("Index");
        }
        public ActionResult User()
        {
            ViewData["Message"] = "只要是注册用户就能访问!";

            return View("Index");
        }
        public ActionResult UserOnly()
        {
            ViewData["Message"] = "只能是User才能能访问!";

            return View("Index");
        }

        public ActionResult Login(string user)
        {
            Session["CurrentUser"] = Database.Users.Find(u => u.Name == user);
            if (Session["CurrentUser"] != null)
            {
                ViewData["Message"] = "你已登录为" + user;
            }

            return View("Index");
        }


        public ActionResult About()
        {
            return View();
        }
    }
}
